const express = require("express")
const path = require("path")
const fs =require("fs/promises")
// npm i exress@4.21.1
const app = express()
//引入跨域插件 npm i cors
const cors = require("cors")
app.use(cors())

//配置静态资源
app.use(express.static(path.resolve(__dirname,"./public")))
//解析post请求(form类型)
// app.use(express.urlencoded({extended: true}))
// 解析post --json类型
app.use(express.json())

// 导入路由
const MonsRouter = require("./router/index")
// 使用路由 /west
app.use("/" , MonsRouter)
// 要访问/west路由 ===》 /hi/west
// app.use("/hi" , MonsRouter)



app.set("view engine","ejs")
app.set("views", path.resolve(__dirname,"./views"))




app.listen(4399, () => {
    console.log("启动成功 \n ---> http://localhost:4399/  \n --->http://127.0.0.1:4399")
})